-
Notifications
You must be signed in to change notification settings - Fork 27
fix: show user predictions on closed numeric and date questions #4042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Removed the isForecastActive() check that was preventing user predictions from being displayed on closed numeric and date questions. The prediction data is available and should be shown regardless of question status. Fixes #4009 Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| </div> | ||
| {showMyPrediction && | ||
| question.my_forecasts?.latest && | ||
| isForecastActive(question.my_forecasts.latest) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude
I suspect we added isForecastActive so we don't show withdrawn predictions. Cases:
- Question open and prediction not withdrawn yet: show.
- Question open and prediction withdrawn: don't show.
- Question closed and prediction not withdrawn before close: show.
- Question closed and prediction withdrawn before close: don't show.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @SylvainChevalier's task in 1m 3s —— View job
Analysis: Withdrawn Predictions Concern
You're absolutely right to be concerned! Here's what I found:
What isForecastActive() Does
From front_end/src/utils/forecasts/helpers.ts:136-138:
export function isForecastActive(forecast: UserForecast | AggregateForecast) {
return isNil(forecast.end_time) || forecast.end_time * 1000 > Date.now();
}This checks if a forecast is not withdrawn by verifying that either:
end_timeis null/undefined (forecast never withdrawn), ORend_timeis in the future (hasn't ended yet)
The Problem with the Current PR
MyPredictionChip ALREADY has the isForecastActive() check inside it (my_prediction_chip.tsx:39), so removing it from the parent seems safe at first glance. However, there's a subtle issue:
The current PR removes the check from prediction_continuous_info.tsx, but prediction_binary_info.tsx:81 still has it. This creates an inconsistency between binary and continuous questions.
Case Analysis
Let me verify all four cases:
| Case | Question State | Prediction State | Should Show? | Current PR Behavior |
|---|---|---|---|---|
| 1 | Open | Not withdrawn | ✅ Show | ✅ Shows (pass isForecastActive in chip) |
| 2 | Open | Withdrawn | ❌ Don't show | ✅ Hidden (fail isForecastActive in chip) |
| 3 | Closed | Not withdrawn before close | ✅ Show | ✅ Shows (pass isForecastActive in chip) |
| 4 | Closed | Withdrawn before close | ❌ Don't show | ✅ Hidden (fail isForecastActive in chip) |
Verdict
The current PR is actually correct! 🎉
The MyPredictionChip component already handles the withdrawn check internally at line 39, so:
- Removing the duplicate check from the parent is correct
- All four cases are handled properly through the child component's check
Recommendation
For consistency, prediction_binary_info.tsx should also have the same fix applied - it currently has a redundant isForecastActive check at line 81 that can be removed since MyPredictionChip handles it.
Would you like me to apply the same fix to the binary version for consistency? Fix this →
Summary
This PR fixes the issue where user predictions were not visible on closed numeric and date questions.
Changes
isForecastActive()check that was preventing predictions from displaying on closed questionsThe prediction data is always available and should be shown regardless of whether the question is closed, matching the behavior in feed tiles and the "Overlay Current Forecast" feature.
Fixes #4009
🤖 Generated with Claude Code